/**
 * Class Local
 * this class is used to save data to localstorage
 */
Local = (function() {
    /**
     * Local constructor
     * @param name {String} key for this data
     * @constructor
     */
    function Local(name) {
        this.name = name;
    }
    /**
     * Set and save data
     * @param data {*} saved data
     * @param ttl {Number} time to live for this data in minutes
     * @returns {*}
     */
    Local.prototype.set = function(data, ttl) {
        this.data = this.data || {};
        this.data.ttl = Date.now() + ((ttl || 10) * 1000 * 60);
        this.data.data = data || this.data.data;
        return localStorage.setItem(this.name, JSON.stringify(this.data));
    };
    /**
     * Get data form
     * @returns {*}
     */
    Local.prototype.getData = function(){
        var _data = this.data || {};
        _data.data = _data.data || {};
        return _data.data;
    };
    /**
     * Get data form localstorage
     * @returns {*} data
     */
    Local.prototype.get = function() {
        this.data = JSON.parse(localStorage.getItem(this.name));
        if (this.data) {
            return this.data.data;
        }
        return void 0;
    };

    return Local;

})();
